package com.cfh.springcloudclientapplication.event;

import javax.swing.*;
import java.awt.event.*;

public class GUIEvent {
    public static void main(String[] args) {
        JFrame frame = new JFrame();

        frame.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.printf("[%s] 事件: %s \n", Thread.currentThread().getName(), e);
            }
        });

        frame.setBounds(300, 300, 400, 300);

        frame.setVisible(true);

        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                frame.dispose();
            }

            @Override
            public void windowClosed(WindowEvent event) {
                System.exit(0);
            }
        });
    }
}
